# -*- encoding=utf8 -*-
"""
RedFlag-TC0000108  （拍摄进入装饰页）文字文本，描边，背景功能
文字使用文本场景
文字使用描边场景
文字清除描边场景
文字使用背景场景
文字清除背景场景
"""
__author__ = "ldm"

import sys
import os

# 获取当前脚本所在目录.py
current_dir = os.path.dirname(os.path.abspath(__file__))
# 获取上级目录.air
parent_dir = os.path.dirname(current_dir)
# 获取上级目录air
grandparent_dir = os.path.dirname(parent_dir)
# 获取和air目录平级的conf、testcase目录路径
conf_dir = os.path.join(grandparent_dir, 'conf')
testcase_dir = os.path.join(grandparent_dir, 'testcase')
# 将conf、testcase目录添加到sys.path
sys.path.append(conf_dir)
sys.path.append(testcase_dir)

from PageFunction import CameraVideoShooter
from elements import *

auto_setup(__file__)
shooter = CameraVideoShooter()

case_text = "这是一条测试数据"
case_Text = "测试编辑文字功能"

log("--------------------------------文字使用文本场景--------------------------------------")
"""
拍摄视频进入装饰页
点击文字
输入文案
选择第四个字体
点击颜色
选择一个文本颜色(9)
点击确定
断言
"""

shooter.enter_photography_decoration_page()
shooter.click_element(decoration_page_text_function)
shooter.input_text_in_element(decoration_page_text_function_input, case_text)
shooter.click_element(decoration_page_text_function_colour)
shooter.click_element(decoration_page_text_function_choice_text[9])
touch((0.45,0.5))
shooter.assert_image_exists(r"tpl1749782148950.png",  "断言失败，预期图片并未出现", record_pos=(0.007, -0.007), resolution=(1224, 2700), threshold=0.9)

log("--------------------------------文字使用描边场景--------------------------------------")
"""
点击文字
进入编辑
点击颜色
点击描边
选择一个描边颜色（1）
点击确认
断言
"""

touch((0.5,0.46))
shooter.click_element(decoration_page_text_editing_edit)
shooter.click_element(decoration_page_text_function_colour)
shooter.click_element(decoration_page_text_function_stroke)
shooter.click_element(decoration_page_text_function_choice_text[1])
shooter.click_element(decoration_page_text_function_confirm)
shooter.assert_image_exists(r"tpl1749782305078.png", "断言失败，预期图片并未出现", record_pos=(0.002, -0.008), resolution=(1224, 2700), threshold=0.9)

log("--------------------------------文字清除描边场景--------------------------------------")
"""
点击文字
进入编辑
点击颜色
点击描边
点击清除按钮
点击确认
断言
"""

touch((0.5,0.46))
shooter.click_element(decoration_page_text_editing_edit)
shooter.click_element(decoration_page_text_function_colour)
shooter.click_element(decoration_page_text_function_stroke)
shooter.click_element(decoration_page_text_function_choice_text[0])
shooter.click_element(decoration_page_text_function_confirm)
shooter.assert_image_exists(r"tpl1749782652393.png", "断言失败，预期图片并未出现", record_pos=(0.0, -0.007), resolution=(1224, 2700), threshold=0.9)

log("--------------------------------文字新增背景场景--------------------------------------")
"""
点击文字
进入编辑
点击颜色
点击背景
选择一个背景
点击确认
断言
"""

touch((0.5,0.46))
shooter.click_element(decoration_page_text_editing_edit)
shooter.click_element(decoration_page_text_function_colour)
shooter.click_element(decoration_page_text_function_background)
shooter.click_element(decoration_page_text_function_choice_text[2])
shooter.click_element(decoration_page_text_function_confirm)
shooter.assert_image_exists(r"tpl1749782978348.png", "断言失败，预期图片并未出现", record_pos=(-0.008, -0.005), resolution=(1224, 2700), threshold=0.9)

log("--------------------------------文字清除描边场景--------------------------------------")
"""
点击文字
进入编辑
点击颜色
点击背景
点击清除按钮
点击确认
断言
"""

touch((0.5,0.46))
shooter.click_element(decoration_page_text_editing_edit)
shooter.click_element(decoration_page_text_function_colour)
shooter.click_element(decoration_page_text_function_background)
shooter.click_element(decoration_page_text_function_choice_text[0])
shooter.click_element(decoration_page_text_function_confirm)
shooter.assert_image_exists(r"tpl1749782652393.png", "断言失败，预期图片并未出现", record_pos=(0.0, -0.007), resolution=(1224, 2700), threshold=0.9)

# 关闭应用
stop_app(UGC_package_name)






